<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="author" content="" />
<link rel="stylesheet" href="../../css/main.css" type="text/css" />
<link href="../../css/themes/default.css" rel="stylesheet" type="text/css"/>
<link href="../../css/themes/mac_os_x.css" rel="stylesheet" type="text/css"/>
<link href="../../css/themes/alphacube.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../js/prototype.js"></script>
<script type="text/javascript" src="../../js/scriptaculous.js"></script>
<script type="text/javascript" src="../../js/page.js"></script>
<script type="text/javascript" src="../../js/window.js"></script>
<script type="text/javascript" src="../../js/window_effects.js"></script>
<script type="text/javascript">
var win;
var messages = new Array('', 'Utente inserito con successo', 'Utente cancellato con successo', 'Utente modificato con successo');
var index = 0;
<?php 
if(isset($_REQUEST['msg'])){
?>
index = <?php print $_REQUEST['msg'] ?>;
<?php } ?>
function user(id){
	if(id == 0)
		high = 450;
	else
		high = 350;
    win = new Window({className: "mac_os_x", url: "dettaglio_utente.php?offset=<?php print $offset ?>&id="+id,  width:600, height:high, zIndex: 100, resizable: true, title: "Dettaglio news", showEffect:Effect.Appear, hideEffect: Effect.Fade, draggable:true, wiredDrag: true});
	win.showCenter(false);
}

</script>
</head>
<body <?php if(isset($_REQUEST['msg'])){ ?>onload="openInfoDialog(messages[<?php print $_REQUEST['msg'] ?>], 2)"<?php } ?>>
    <div id="header">
		<div class="wrap" style="text-align: center">
			<?php include "../header.php" ?>
		</div>
	</div>
	<div class="wrap">
	<div id="main" style="background-color: #FFFFFF; padding-bottom: 30px; width: 100%">
        <table class="admin_table">
            <tr class="admin_title_row">
                <td colspan="3">Elenco Utenti: pagina <?php print $page ?> di <?php print $pagine ?></td>
            </tr>
            <tr class="admin_row">
                <td style="width: 40%" class="adm_titolo_elenco">Nome e cognome</td>
                <td style="width: 20%" class="adm_titolo_elenco">Username</td>
                <td style="width: 40%" class="adm_titolo_elenco _center">Gruppi</td>
            </tr>
            <tr class="admin_row">
                <td colspan="3"></td>
            </tr>
            <?php
            $x = 1;
            if($res_user->num_rows > $limit)
                $max = $limit;
            else
                $max = $res_user->num_rows;

            while($user = $res_user->fetch_assoc()){
                if($x > $limit) break;
                // estraggo i gruppi di appartenenza
                $sel_gruppi = "SELECT gid, nome, codice FROM gruppi WHERE gid IN (".$user['gruppi'].")";
                //print $sel_gruppi;
                $res_gruppi = $db->execute($sel_gruppi);
                $gruppi = "";
                while($g = $res_gruppi->fetch_assoc()){
                    $gruppi .= $g['nome'].", ";
                }
                $gruppi = substr($gruppi, 0, ($gruppi - 2));
            ?>
            <tr>
                <td class="admin_row<?php if($x % 2) print(" odd") ?>"><a href="#" onclick="user(<?php print $user['uid'] ?>)"><?php print $user['cognome']." ".$user['nome'] ?></a></td>
                <td class="admin_row<?php if($x % 2) print(" odd") ?>"><?php print $user['username'] ?></td>
                <td class="admin_row _center<?php if($x % 2) print(" odd") ?>"><?php print $gruppi ?></td>
            </tr>
            <?php
                $x++;
            }
            include "../../shared/navigate.php";
            ?>
            <tr class="admin_row admin_menu">
                <td colspan="3">
                	<a href="#" onclick="user('0')" class="nav_link_first">Nuovo utente</a>|
                    <a href="<?php print $_SESSION['__config__']['html_root'] ?>admin/index.php" class="nav_link_last">Torna menu</a>
                </td>
            </tr>
            <tr class="admin_row">
                <td colspan="3"></td>
            </tr>
        </table>
        </div>
        <div id="footer">
			<p>Design: Luka Cvrk - <a href="http://www.solucija.com" title="Free Web Templates">Solucija</a></p>
		</div>
	</div>
</body>
</html>